import cv2
import matplotlib.pyplot as plt
import numpy as np


def show(img):
    cv2.imshow("img", img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()


pie = cv2.imread("./01_Picture/06_pie.png", cv2.IMREAD_GRAYSCALE)
sobelx = cv2.Sobel(pie, cv2.CV_64F, 1, 0, ksize=3)
sobelx = cv2.convertScaleAbs(sobelx)
show(sobelx)
sobely = cv2.Sobel(pie, cv2.CV_64F, 0, 1, ksize=3)
sobely = cv2.convertScaleAbs(sobely)
show(sobely)
sobelxy = cv2.addWeighted(sobelx, 0.5, sobely, 0.5, 1)
show(sobelxy)


lena = cv2.imread("./01_Picture/13_Lena.jpg", cv2.IMREAD_GRAYSCALE)
sobelx2 = cv2.Sobel(lena, cv2.CV_64F, 1, 0, ksize=3)
sobelx2 = cv2.convertScaleAbs(sobelx2)
show(sobelx2)
sobely2 = cv2.Sobel(lena, cv2.CV_64F, 0, 1, ksize=3)
sobely2 = cv2.convertScaleAbs(sobely2)
show(sobely2)
sobelxy2 = cv2.addWeighted(sobelx2, 0.5, sobely2, 0.5, 1)
show(sobelxy2)

res = np.hstack((sobelx, sobely, sobelxy))
show(res)
res = np.hstack((sobelx2, sobely2, sobelxy2))
show(res)




